/*
 * @Author: your name
 * @Date: 2020-06-29 14:55:43
 * @LastEditTime: 2020-07-07 15:28:54
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \thinkjs-test\src\controller\PushController.js
 */ 
const Base = require('./base.js');
export default class extends Base {
    constructor(args){
        super(args);
        this.pushService = this.service('PushRAV2Service');
    }
   
    /**
     * @api {post} /PushController/pushMessageToSingle 单推 by cid
     * @apiDescription 单推 by cid
     * @apiName pushMessageToSingle
     * @apiGroup getui
     * @apiParam {string} cid 用户设备唯一标识cid    
     * @apiSuccess {json} result
     * @apiSuccessExample {json} Success-Response:
     * {
            "errno": 0,
            "errmsg": "",
            "data": {
                "result": "ok",
                "taskId": "OSS-0702_54a3faaac5538097422b9d954810ef1f",
                "status": "successed_offline"
            }
        }   
     * @apiSampleRequest /foreign/v1/crime/BqjlController/getBqjlById
     * @apiVersion 1.0.0
     */
    async pushMessageToSingleAction(){
        const data = this.post();
        const ret = await this.pushService.pushMessageToSingle(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }

    async pushMessageToAppAction(){
        const data = this.post();
        const ret = await this.pushService.pushMessageToApp(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }

    /**
     *绑定别名 单用户
     *
     */
    async bindAliasAction(){
        const data = this.post();
        console.log(data);
        const ret = await this.pushService.bindAlias(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }

    /**
     *绑定别名 多用户
     *
     */
    async bindAliasListAction(){
        const data = this.post();
        console.log(data);
        const ret = await this.pushService.bindAliasList(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }

    /**
     *根据别名获取clientid信息
     *
     */
    async queryClientIdAction(){
        const data = this.post();
        const ret = await this.pushService.queryClientId(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }

    /**
     *通过clientid获取别名信息
     *
     */
    async queryAliasAction(){
        const data = this.post();
        const ret = await this.pushService.queryAlias(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }
    
    /**
     *对指定用户列表推送消息tolist
     *
     */
    async pushMessageToListAction(){
        const data = this.post();
        const ret = await this.pushService.pushMessageToList(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }

    /**
     *对指定用户列表推送消息tolist
     *
     */
    async setClientTagAction(){
        const data = this.post();
        const ret = await this.pushService.setClientTag(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }
    
    /**
     *对指定用户列表推送消息tolist
     *
     */
    async getUserTagsAction(){
        const data = this.post();
        const ret = await this.pushService.getUserTags(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }

    async removeAliasAction(){
        const data = this.post();
        const ret = await this.pushService.removeAlias(data);
        
        console.log(ret);
        if(ret){
            this.success(ret)
        }
    }
    
  }